home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / VOXRAY.ZIP / GAMERUN.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-22  |  16.2 KB  |  684 lines

  1. #include <mem.h>
  2. #include <string.h>
  3. #include <stdarg.h>
  4. #include <fstream.h>
  5. #include "utils.h"
  6. #ifdef OS_DOS
  7. #include "mouse.h"
  8. #include <dos.h>
  9. #endif
  10. #include "ray.h"
  11. #include "scrcntl.h"
  12. #include "palette.h"
  13. #include "screen.h"
  14. #include "globals.h"
  15. #include "resnames.h"
  16. #include "waves.h"
  17. #include "voxinter.h"
  18. #include "scrcap.h"
  19. #include "shading.h"
  20. #include "skipping.h"
  21. #include "sound.h"
  22. #include "sprinter.h"
  23. #include "playint.h"
  24. #include "keyinfo.h"
  25. #include "raywidth.h"
  26. #include "loadwor.h"
  27. #include "keyboard.h"
  28. #include "raybuff.h"
  29. #include "timer.h"
  30. #include "gentree.h"
  31. #include "dosfuncs.h"
  32. #include "winfuncs.h"
  33. #include "scrconf.h"
  34. #include "quit.h"
  35. #include "rgobject.h"
  36. #include "ground.h"
  37. #include "closers.h"
  38. #include "visuals.h"
  39. #include "scrmes.h"
  40. #include <stdio.h>
  41.  
  42. #define _PROGRAMMER_VERSION_
  43.  
  44. #define UPDATE_SPEED 36.5
  45.  
  46. #define MAX_ARG_LENGTH 20
  47. #define NORM_ARG 1
  48. #define FILE_ARG 2
  49. #define WTEX_ARG 3
  50. #define FTEX_ARG 4
  51.  
  52. #define PLAYER_START_X (1925<<SHIFT)
  53. #define PLAYER_START_Y (550<<SHIFT)
  54. #define PLAYER_START_ANGLE ANGLE_180
  55. #define PLAYER_START_Z 8
  56.  
  57. #ifdef OS_DOS
  58. #define VGA_WIDTH 320
  59. #define VGA_HEIGHT 200
  60. #define SVGA_WIDTH 640
  61. #define SVGA_HEIGHT 480
  62. #endif
  63.  
  64. #define HURT_TIME 10
  65. #define STANDARD_PAL 0
  66. #define HURT_PAL 1
  67.  
  68. extern "C" int _argc;
  69. extern "C" char ** _argv;
  70.  
  71. typedef BOOL dimension_control_type;
  72. #define VERT_CONTROL TRUE
  73. #define HORIZ_CONTROL FALSE
  74.  
  75. const char DEF_WORLD [F_NAME_LENGTH]="nraymap.dat";
  76. const char FILE_CMD [MAX_ARG_LENGTH]="-file";
  77. const char WTEX_CMD [MAX_ARG_LENGTH]="-wtex";
  78. const char FTEX_CMD [MAX_ARG_LENGTH]="-ftex";
  79. const char NO_SHADE_CMD [MAX_ARG_LENGTH]="-noshade";
  80. const char WAVE_CMD [MAX_ARG_LENGTH]="-wave";
  81. const char DEF_CAPTURE_F_NAME[F_NAME_LENGTH]="scrcap.pcx";
  82. const char END_PICT_NAME[F_NAME_LENGTH]="end.pcx";
  83. const char SKIP_CMD [MAX_ARG_LENGTH]="-fastvox";
  84.  
  85. BOOL do_waves;
  86.  
  87. BOOL is_super_vga;
  88.  
  89. ULONG frame_num=0;
  90.  
  91. void Analyze_Args();
  92.  
  93. void World_Update(long cur_update_num);
  94.  
  95. void Setup_Combined_Input();        
  96.  
  97. void Start_Palette();
  98.  
  99. extern int raw_key;                  // the global raw keyboard data aquired from the ISR
  100.  
  101. extern int key_table[MAX_TRACKED_INPUTS-1]; // the key state table for the motion keys
  102.  
  103. void Clear_Input();
  104.  
  105. #ifdef OS_DOS
  106. void GetMouseInput(); // Routine to set the mouse statement flags
  107. #endif
  108.  
  109. int mouse_table[MAX_TRACKED_INPUTS-1] = {0,0,0,0,0,0}; // same state table thing but for the mouse
  110.  
  111. short combined_table[MAX_TRACKED_INPUTS]= {0,0,0,0,0,0,0}; // combination of mouse+keyboard
  112.  
  113. #ifdef OS_DOS
  114. BOOL hasmouse=FALSE; // Boolean for whether the comp. has a mouse
  115. #endif
  116.  
  117. dimension_control_type dim_control;
  118.  
  119. BOOL done;
  120.  
  121. void startup();
  122. void shutdown();
  123.  
  124. void Global_Initialize() {
  125.     Screen_Message("Initializing Hardware!");
  126.     startup(); // Setup hardware stuff, etc.
  127.     Screen_Message("Initializign Renderer!");
  128.     initRay(); // Setup raycaster
  129.     Screen_Message("Loading data!");
  130.     Analyze_Args();           
  131. }
  132.  
  133. extern "C" Shutdown() {
  134. #ifdef OS_DOS
  135. Dos_Close();
  136. #endif
  137.  
  138. #ifdef OS_WINDOWS
  139. Win_Close();
  140. #endif
  141. }
  142.  
  143. extern "C" void Error(char * error) {
  144. Shutdown();
  145. printf(error);
  146. printf("\n");
  147. exit(1);
  148. }
  149.  
  150. void Global_Close() {
  151.     closeRay(); // Shut down the raycaster
  152.     shutdown(); // Clear up memory and reset hardware
  153. }
  154.                             
  155. void Analyze_Args()
  156. {
  157. LONG arg_type;
  158. LONG cur_arg_num;
  159. PCHAR cur_argument;
  160.  
  161. arg_type=NORM_ARG;
  162. cur_arg_num=1;
  163. do_waves=FALSE;
  164.  
  165. Set_Player_Input_Buffer(combined_table);
  166. F_Scan_Load((PCHAR)DEF_WORLD);
  167. Set_Shading(SHADING_ON);
  168. Set_Skipping(SKIPPING_OFF);
  169. // go through arguments looking for user specifications
  170.  
  171. while (cur_arg_num<_argc) {
  172.  
  173.     cur_argument=_argv[cur_arg_num];
  174.  
  175.     // what type of argument is this 
  176.     switch (arg_type) {
  177.     
  178.     // normal:
  179.     case NORM_ARG:
  180.  
  181.         // is the user specifying a world file name?
  182.         if (!strnicmp(cur_argument, FILE_CMD, MAX_ARG_LENGTH))
  183.             arg_type=FILE_ARG;
  184.  
  185.         if (!strnicmp(cur_argument, WTEX_CMD, MAX_ARG_LENGTH))
  186.             arg_type=WTEX_ARG;
  187.  
  188.         if (!strnicmp(cur_argument, FTEX_CMD, MAX_ARG_LENGTH))
  189.             arg_type=FTEX_ARG;
  190.         
  191.         if (!strnicmp(cur_argument, WAVE_CMD, MAX_ARG_LENGTH))
  192.             do_waves=TRUE;
  193.  
  194.         if (!strnicmp(cur_argument, NO_SHADE_CMD, MAX_ARG_LENGTH))
  195.             Set_Shading(SHADING_OFF);
  196.  
  197.         if (!strnicmp(cur_argument, SKIP_CMD, MAX_ARG_LENGTH))
  198.             Set_Skipping(SKIPPING_ON);
  199.  
  200.         break;
  201.  
  202.     // file name:
  203.     case FILE_ARG:
  204.  
  205.         Load_World(cur_argument);
  206.         arg_type=NORM_ARG;
  207.         break;
  208.  
  209.     //wall texture file name
  210.     case WTEX_ARG:
  211.  
  212.         F_Spec_Load(1, cur_argument, (PCHAR)WTEX_RES);
  213.         arg_type=NORM_ARG;
  214.         break;
  215.  
  216.     //floor texture file name
  217.     case FTEX_ARG:
  218.  
  219.         F_Spec_Load(1, cur_argument, (PCHAR)FTEX_RES);
  220.         arg_type=NORM_ARG;
  221.         break;
  222.  
  223.     default:
  224.         break;
  225.  
  226.     }
  227.  
  228.     cur_arg_num++;
  229. }  
  230.  
  231. the_player=Create_Object(PLAYER_START_X, PLAYER_START_Y, PLAYER_START_Z,
  232.     PLAYER_START_ANGLE, PLAYER_TYPE, NULL, 3);
  233. Gen_Tree();
  234. Setup_Anim_Tex();
  235. }     
  236.     
  237. UCHAR paldata[5][768];
  238. void Start_Palette() {
  239.     Init_Palette();
  240.     fstream fp;
  241.     fp.open("standard.pal",ios::binary | ios::in | ios::out);
  242.     fp.seekg(0L,ios::beg);
  243.     fp.read(paldata[0],768);
  244.     fp.close();
  245.     fp.open("red.pal", ios::binary | ios::in | ios::out);
  246.     fp.seekg(0L,ios::beg);
  247.     fp.read(paldata[1],768);
  248.     fp.close();
  249.     Load_Palette(paldata[0], 0, 256);
  250. }
  251.  
  252. void Show_Palette(short pal_handle) {
  253.     Load_Palette(paldata[pal_handle], 0, 256);
  254.     Activate_Palette(TRUE);
  255. }
  256.  
  257. void startup()      
  258. {
  259.     Init_Timer();
  260.     Start_Palette();
  261.  
  262. #ifdef OS_DOS
  263.     if (initmouse()) { // Setup mouse
  264.         hasmouse=TRUE;
  265.         hidemouse();
  266.     } else hasmouse=FALSE;
  267. #endif
  268.  
  269. Init_Sound(); 
  270. Init_Keyboard();
  271. }
  272.  
  273. void shutdown()
  274. {
  275.     Close_Keyboard();
  276.     Close_Timer();
  277.     Close_Sound();
  278.     End_Graphics();
  279.     Close_Palette();
  280. }
  281.  
  282. angle_type cur_vert_angle, last_vert_angle;
  283. long beg_update_num;
  284.  
  285. void Do_Intro() {
  286.  
  287. Play_Sound(Load_Sound("yo.wav"));
  288.  
  289. long abs_z;
  290. RCastGobject picts(4);
  291. long start_update_num;
  292.  
  293. picts.assigninfile("3.pcx");
  294. picts.load(0);
  295. picts.assigninfile("2.pcx");
  296. picts.load(1);
  297. picts.assigninfile("1.pcx");
  298. picts.load(2);
  299. picts.assigninfile("go.pcx");
  300. picts.load(3);
  301.  
  302. for (short cur_pict=0; cur_pict<4; cur_pict++) {
  303.  
  304.           cur_vert_angle=Get_Player_Vert_Angle(the_player);
  305.           if (cur_vert_angle!=last_vert_angle) {
  306.               Set_View_Angle(cur_vert_angle);
  307.               last_vert_angle=cur_vert_angle;
  308.           }
  309.           if (the_player->cur_sec->flags & VOXEL_SECTOR) {
  310.         abs_z=the_player->z+Get_Voxel_Alt((PUCHAR)the_player->cur_sec->extra_data,
  311.                              the_player->x, the_player->y)+the_player->type->eye_height;
  312.     } else {
  313.               abs_z=the_player->z+the_player->cur_sec->floor_height+the_player->type->eye_height;
  314.           }
  315.           Render_Screen(the_player->x, the_player->y, abs_z, the_player->angle);
  316.           picts.transparent_show(buff, Get_Phys_Screen_Width(), 0,0, cur_pict);
  317. #ifdef OS_WINDOWS
  318.           Win_Copy_Buff();
  319. #endif
  320. #ifdef OS_DOS
  321.           Dos_Copy_Buff();
  322. #endif
  323.           // wait a bit
  324.           start_update_num=Get_Update_Num();
  325.           while ((start_update_num+36)>Get_Update_Num()); /* endwhile */
  326.     }
  327. Start_Music();
  328. }
  329.  
  330. void Post_Quit(ULONG game_result) {
  331.     long abs_z;
  332.     RCastGobject end_scrn;
  333.           Stop_Music();
  334.     if (game_result==WINNING_GAME) {
  335.           Play_Sound(Load_Sound("king.wav"));
  336.           end_scrn.assigninfile((PCHAR)END_PICT_NAME);
  337.           end_scrn.load();
  338.           cur_vert_angle=Get_Player_Vert_Angle(the_player);
  339.           if (cur_vert_angle!=last_vert_angle) {
  340.               Set_View_Angle(cur_vert_angle);
  341.               last_vert_angle=cur_vert_angle;
  342.           }
  343.           if (the_player->cur_sec->flags & VOXEL_SECTOR) {
  344.         abs_z=the_player->z+Get_Voxel_Alt((PUCHAR)the_player->cur_sec->extra_data,
  345.                              the_player->x, the_player->y)+the_player->type->eye_height;
  346.     } else {
  347.               abs_z=the_player->z+the_player->cur_sec->floor_height+the_player->type->eye_height;
  348.           }
  349.           Render_Screen(the_player->x, the_player->y, abs_z, the_player->angle);
  350.           end_scrn.transparent_show(buff, Get_Phys_Screen_Width(), 0,0);
  351. #ifdef OS_WINDOWS
  352.           Win_Copy_Buff();
  353. #endif
  354. #ifdef OS_DOS
  355.           Dos_Copy_Buff();
  356. #endif
  357.           raw_key=0;
  358.           long start_update_num;
  359.           start_update_num=Get_Update_Num();
  360.           while ( ((start_update_num+200)>Get_Update_Num()) && (!raw_key) );
  361.      }
  362.     if (game_result==DIED_GAME) {
  363.         setgmode(0x3);
  364.         cout << "Just because you're paranoid, doesn't mean they're not out to get you.\n";
  365.         delay(5000);
  366.     }
  367. done=TRUE;
  368. }
  369.  
  370. void Do_Shot(PCHAR graphic_filename, PCHAR sound_filename, long time, BOOL back) {
  371.     Suspend_Time();
  372.     RCastGobject scrn;
  373.     scrn.assigninfile(graphic_filename);
  374.     scrn.load();
  375.  
  376.     if (back) {
  377.     cur_vert_angle=Get_Player_Vert_Angle(the_player);
  378.     if (cur_vert_angle!=last_vert_angle) {
  379.         Set_View_Angle(cur_vert_angle);
  380.         last_vert_angle=cur_vert_angle;
  381.     }
  382.     Render_Screen(the_player->x, the_player->y, the_player->z+the_player->type->eye_height+
  383.         Ground_Height(the_player), the_player->angle);
  384.     } else clearBuff();
  385.  
  386.     scrn.transparent_show(buff, Get_Phys_Screen_Width(), 0, 0);
  387. #ifdef OS_WINDOWS
  388.     Win_Copy_Buff();
  389. #endif
  390. #ifdef OS_DOS
  391.     Dos_Copy_Buff();
  392. #endif
  393.     Play_Sound(Load_Sound(sound_filename));
  394.     Reset_Timer();
  395.     while (Get_Update_Num()<time);
  396.     Resume_Time();
  397. }
  398.  
  399. void Init_Main_Cycle() {
  400.     Reset_Timer();
  401.     Do_Intro();
  402.     Reset_Timer();
  403. #ifdef OS_DOS
  404.     if (hasmouse)
  405.       GetMouseInput();
  406. #endif
  407.     Clear_Input();
  408.     beg_update_num=0;
  409.     cur_vert_angle=last_vert_angle=0;
  410.     dim_control=VERT_CONTROL;
  411.     raw_key=0;
  412. #ifdef OS_DOS
  413.     done=FALSE;
  414. #endif
  415. }
  416.  
  417. BOOL Main_Cycle_Done() {
  418.     return done;
  419. }
  420.  
  421. void Do_Main_Cycle()
  422. {
  423. long abs_z;
  424. long cur_update, end_update_num;
  425.  
  426.           cur_vert_angle=Get_Player_Vert_Angle(the_player);
  427.           if (cur_vert_angle!=last_vert_angle) {
  428.               Set_View_Angle(cur_vert_angle);
  429.               last_vert_angle=cur_vert_angle;
  430.           }
  431.           if (the_player->cur_sec->flags & VOXEL_SECTOR) {
  432.         abs_z=the_player->z+Get_Voxel_Alt((PUCHAR)the_player->cur_sec->extra_data,
  433.                              the_player->x, the_player->y)+the_player->type->eye_height;
  434.     } else {
  435.               abs_z=the_player->z+the_player->cur_sec->floor_height+the_player->type->eye_height;
  436.           }
  437.           Render_Screen(the_player->x, the_player->y, abs_z, the_player->angle);
  438. #ifdef OS_WINDOWS
  439.           Win_Copy_Buff();
  440. #endif
  441. #ifdef OS_DOS
  442.           Dos_Copy_Buff();
  443. #endif
  444.           frame_num++; 
  445.  
  446.           end_update_num=Get_Update_Num();
  447.           for (cur_update=beg_update_num; cur_update<end_update_num; cur_update++) {
  448.               World_Update(cur_update);
  449.           }
  450.           beg_update_num=end_update_num;
  451.  
  452.           // Check other keys that are unrelated to world updates
  453.  
  454.           switch (raw_key) {
  455.           case ESC_KEY:
  456.  #ifdef OS_DOS
  457.               done=TRUE;
  458. #endif
  459. #ifdef OS_WINDOWS
  460.               PostQuitMessage(0);
  461. #endif
  462.               // end if user is exiting
  463.               break;
  464. #ifdef _PROGRAMMER_VERSION_
  465.           case PLUS_KEY:
  466.               // user pressed "+" key, so increase window size
  467.               if (GetRenderMode()!=MODE_2D) {
  468.                   #ifdef OS_DOS
  469.                   if (dim_control==VERT_CONTROL)
  470.                       setWindowDimensions(WINDOW_HEIGHT+10);
  471.                   else if (dim_control==HORIZ_CONTROL)
  472.                       Set_Window_Width(WINDOW_WIDTH+10);
  473.                   #endif
  474.               } else Map_Scale_Increase();
  475.               break;
  476.           case MINUS_KEY:
  477.               // user pressed "-" key, so decrease window size
  478.               if (GetRenderMode()!=MODE_2D) {
  479.                   #ifdef OS_DOS
  480.                   if (dim_control==VERT_CONTROL)
  481.                       setWindowDimensions(WINDOW_HEIGHT-10);
  482.                   else if (dim_control==HORIZ_CONTROL)
  483.                       Set_Window_Width(WINDOW_WIDTH-10);
  484.                   #endif
  485.               } else Map_Scale_Decrease();
  486.               break;
  487.           case RIGHT_BRACKET:
  488.               // user pressed "]" key, so increase window FOV
  489.              if (dim_control==VERT_CONTROL)
  490.                  setWindowFOV(VERTICAL_VIEW_RANGE+ANGLE_5);
  491.              else if (dim_control==HORIZ_CONTROL)
  492.                  Set_Horiz_FOV(HORIZ_VIEW_RANGE+ANGLE_5);
  493.              break;
  494.           case LEFT_BRACKET:
  495.              // user pressed "[" key, so decrease window FOV
  496.              if (dim_control==VERT_CONTROL)
  497.                  setWindowFOV(VERTICAL_VIEW_RANGE-ANGLE_5);
  498.              else if (dim_control==HORIZ_CONTROL)
  499.                  Set_Horiz_FOV(HORIZ_VIEW_RANGE-ANGLE_5);
  500.              break;
  501.          case PGUP_KEY:
  502.              // user wants to make vox terrain seem farther away
  503.              V_Dist_Scale_Inc();
  504.              break;
  505.          case PGDN_KEY:
  506.              // user wants to make vox terrain seem closer
  507.              V_Dist_Scale_Dec();
  508.              break;
  509. #endif
  510. #ifdef OS_DOS
  511.          case F1_KEY:
  512.              // user is changing screen resolution
  513.              if (is_super_vga)
  514.                  Change_Screen(VGA_WIDTH, VGA_HEIGHT);
  515.              else Change_Screen(SVGA_WIDTH, SVGA_HEIGHT);
  516.              is_super_vga=(!is_super_vga);
  517.              Update_Palette();
  518.              break;
  519. #endif
  520. #ifdef _PROGRAMMER_VERSION_
  521.          case F2_KEY:
  522.              // user wants to adjust the other dimension of screen
  523.              if (dim_control==VERT_CONTROL)
  524.                  dim_control=HORIZ_CONTROL;
  525.              else if (dim_control==HORIZ_CONTROL)
  526.                  dim_control=VERT_CONTROL;
  527.              raw_key=0;
  528.              break;
  529. #endif
  530.          case S_KEY:
  531.              // user wants to capture screen
  532.              Screen_Capture((PCHAR)DEF_CAPTURE_F_NAME);
  533.              break;
  534.           case TAB_KEY:
  535.               SwitchRenderMode();
  536.               raw_key=0;
  537.               break;
  538.           default:
  539.              break;
  540.           } /* endswitch */
  541. }
  542.  
  543. long time_at_hurt;
  544. BOOL is_hurt;
  545.  
  546. void Init_Visuals() {
  547. time_at_hurt=0;
  548. is_hurt=FALSE;
  549. }
  550.  
  551. void Visuals_Message(ULONG message, pdata extra_data) {
  552. switch (message) {
  553.   case HURT_MESSAGE:
  554.       Show_Palette(HURT_PAL);
  555.       time_at_hurt=Get_Update_Num();
  556.       is_hurt=TRUE;
  557.       break;
  558.   case VIS_DIE_MSG:
  559.       Do_Shot("dscreen.pcx", "aaah.wav", 90, TRUE);
  560.       the_player->x=PLAYER_START_X;
  561.       the_player->y=PLAYER_START_Y;
  562.       the_player->z=PLAYER_START_Z;
  563.       the_player->stats.current_health=the_player->type->stats.total_health;
  564.       the_player->angle=PLAYER_START_ANGLE;
  565.   default:
  566.       break;
  567. }
  568. }
  569.  
  570. void Visuals_Update(long cur_update_num) {
  571. if (is_hurt) {
  572.   if (cur_update_num>time_at_hurt+HURT_TIME) {
  573.      is_hurt=FALSE;
  574.      time_at_hurt=0;
  575.      Show_Palette(STANDARD_PAL);
  576.   }
  577. }
  578. }
  579.  
  580. void World_Update(long cur_update_num) {
  581.  
  582. #ifdef OS_DOS
  583.     if (hasmouse)
  584.         GetMouseInput();
  585. #endif
  586.  
  587.     if (do_waves) {
  588.         Do_Waves();
  589.     } /* endif */
  590.  
  591.     Animate_Textures(cur_update_num);
  592.     Setup_Combined_Input();
  593.     Update_Objects(cur_update_num);
  594.     Visuals_Update(cur_update_num);
  595. }
  596.  
  597. void GetMouseInput()
  598. {
  599.     #ifdef OS_DOS
  600.     short x,y; // x,y positions of the mouse relative to last check
  601.     mbrel(x,y); // Get them's positions;
  602.     if (x<0) { // mouse to left
  603.         mouse_table[INDEX_LEFT]=-x;
  604.     } else {
  605.         if (x>0) { // mouse to right
  606.             mouse_table[INDEX_RIGHT]=x;
  607.         } else {  // no mouse movement on x
  608.             mouse_table[INDEX_LEFT]=0; mouse_table[INDEX_RIGHT]=0;
  609.         } /* endif */
  610.     } /* endif */
  611.     // Note: on the y axis, direction is reversed i.e. a mouse movement up generates a y<0
  612.  
  613.     // mouse has different function in fly mode
  614.     if (!Is_Flying(the_player)) {
  615.         if (y<0) { // mouse is higher than last position
  616.             if (y<-the_player->type->stats.base_speed)
  617.                 y=-the_player->type->stats.base_speed;
  618.  
  619.             mouse_table[INDEX_UP]=-y;
  620.         } else {
  621.             if (y>0) { // mouse is lower than last position
  622.                 if (y>the_player->type->stats.base_speed)
  623.                     y=the_player->type->stats.base_speed;
  624.                 mouse_table[INDEX_DOWN]=y;
  625.             } else { // no mouse movement on y
  626.                 mouse_table[INDEX_DOWN]=0; mouse_table[INDEX_UP]=0;
  627.             } /* endif */
  628.         } /* endif */
  629.         if (mbpos(x,y)) { // Check for button press
  630.             mouse_table[INDEX_GUN]=1;
  631.         } else {
  632.             mouse_table[INDEX_GUN]=0;
  633.         }
  634.     } else {
  635.         if (y<0) {
  636.             mouse_table[LOOK_UP]=-y;
  637.         } else {
  638.             if (y>0) {
  639.                 mouse_table[LOOK_DOWN]=y;
  640.             } else {
  641.                 mouse_table[LOOK_UP]=0; mouse_table[LOOK_DOWN]=0;
  642.             } /* endif */
  643.         } /* endif */
  644.         long mb_press=mbpos(x,y);
  645.         if (mb_press & ML_BUTTON) {
  646.             mouse_table[INDEX_UP]=the_player->type->stats.base_speed;
  647.         } else {
  648.             if (mb_press & MR_BUTTON) {
  649.                 mouse_table[INDEX_DOWN]=the_player->type->stats.base_speed;
  650.             } else {
  651.                 mouse_table[INDEX_UP]=0; mouse_table[INDEX_DOWN]=0;
  652.             } /* endif */
  653.         } /* endif */
  654.     } /* endif */
  655. #endif
  656. }
  657.  
  658. void Setup_Combined_Input()
  659. {
  660.     for (short i=0; i<(MAX_TRACKED_INPUTS-1); i++) {
  661.         if (key_table[i]>mouse_table[i]) {
  662.             combined_table[i]=(short)key_table[i];
  663.         } else {
  664.             combined_table[i]=(short)mouse_table[i];
  665.         } /* endif */
  666.     } /* endfor */
  667.     combined_table[MAX_TRACKED_INPUTS-1]=raw_key;
  668. }
  669.  
  670. void Clear_Input() {
  671.     for (short i=0; i<(MAX_TRACKED_INPUTS-1); i++) {
  672.         key_table[i]=0;
  673.         mouse_table[i]=0;
  674.         combined_table[i]=0;
  675.     }
  676.     raw_key=0;
  677.     combined_table[MAX_TRACKED_INPUTS-1]=0;
  678. }
  679.  
  680. void Screen_Message(PCHAR message) {
  681.   printf(message);
  682.   printf("\n");
  683. }
  684.